package cjq.demo.thread.ch7_2;

import java.util.Date;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Created by Administrator on 2016/5/6.
 */
public class MyExecutor extends ThreadPoolExecutor {

    private ConcurrentHashMap<String,Date> startTimes;

    public MyExecutor(int corePoolSize,int maximumPoolSize,long keepAliveTime,TimeUnit unit,BlockingQueue<Runnable> workQueue){
        super(corePoolSize,maximumPoolSize,keepAliveTime,unit,workQueue);
        startTimes = new ConcurrentHashMap<>();
    }

    public void shutdown(){
        System.out.println("MyExecutor : Going to shutdown.");
        System.out.println("MyExecutor: Executed tasks : "+getCompletedTaskCount());
        System.out.println("MyExecutor:Running tasks: "+getActiveCount());
        System.out.println("MyExecutor: Pending  tasks : "+getQueue().size());
        super.shutdown();
    }
}
